-- card: 3058 from stack: in -- bmap block id: 0 -- flags: 0000 -- background id: 2726 -- name: ----- HyperTalk script ----- on opencard clearboard end opencard on begin set cursor to watch randomboard setboard end begin on imclicked global gottile,gotcolors,gottilenum,map,score,hintpenalty,oldscore if visible of btn "Begin" is true then exit imclicked if gottile = "" then put number of target into gottilenum put short name of btn gottilenum into gotcolors set name of btn gottilenum to "" put rect of target into gottile colorizehc "move",gottile,rect of btn "Spot" colorizehc "colorfill",gottile,"0,0,0" go to this cd play click else get rect of target if it ≠ gottile then colorizehc "move",it,gottile colorizehc "colorfill",it,"0,0,0" go to this cd play click set name of btn gottilenum to short name of btn (number of target) set name of btn (number of target) to "" add 1 to score add hintpenalty to score end if colorizehc "move",rect of btn "Spot",it colorizehc "colorfill",rect of btn "Spot","0,0,0" go to this cd play click set name of btn (number of target) to gotcolors put "" into gottile flush end if if score > 999 then put "000" into score get length(score) if it = 1 then put "00" before score else if it = 2 then put "0" before score get length(oldscore) if it = 1 then put "00" before oldscore else if it = 2 then put "0" before oldscore if score ≠ oldscore then repeat with a = 1 to 3 if char a of score ≠ char a of oldscore then colorizehc "add",("Digit"&char a of score),rect of btn ("Score"&a) end repeat end if put score into oldscore go to this cd end imclicked on clearboard global gottile,map,boardsize,numcolors if boardsize = "" then put 3 into boardsize if numcolors = "" then put 10 into numcolors put "" into gottile put "" into map set cursor to watch colorizehc "colorfill",rect of this cd,"0,0,0" colorizehc "add","SmallTitle",rect of btn "SmallTitle" colorizehc "add","Begin1",rect of btn "Won" colorizehc "add","Help",rect of btn "Help" colorizehc "add","Tiles",rect of btn "Tiles" drawtiles colorizehc "add","Colors",rect of btn "Colors" drawcolors repeat with a = 1 to 3 colorizehc "add","Digit0",rect of btn ("Score"&a) end repeat go to this cd show btn "Begin" end clearboard on setboard global gottile,map,boardsize,score put 0 into score put "" into gottile put "Black,White,Red,Blue,Yellow,Brown,Green,Purple,Orange,Grey" into colors set cursor to watch put "237,87,274,124" into mainrect put "242,71,269,98"&return& "251,88,260,98"&return& "263,92,290,119"&return& "263,101,272,110"&return& "242,113,269,138"&return& "251,112,260,122"&return& "221,92,248,119"&return& "239,101,248,110" into allrects colorizehc "colorfill",rect of this cd,"0,0,0" colorizehc "add","SmallTitle",rect of btn "SmallTitle" colorizehc "add","Help",rect of btn "Help" repeat with a = 1 to 3 colorizehc "add","Digit0",rect of btn ("Score"&a) end repeat colorizehc "add","Tiles",rect of btn "Tiles" drawtiles colorizehc "add","Colors",rect of btn "Colors" drawcolors colorizehc "add","Won1",rect of btn "Won" colorizehc "add","Tile",mainrect repeat with c = 1 to boardsize repeat with b = 1 to boardsize put ((c-1)*5+b) into cb put 1 into rectnum put short name of btn cb into tilepat repeat with a = 1 to 4 get (line rectnum of allrects) colorizehc "add",item (item a of tilepat) of colors,item 1 to 2 of it,line rectnum+1 of allrects add 2 to rectnum end repeat colorizehc "copy",mainrect,rect of btn cb end repeat end repeat colorizehc "colorfill",mainrect,"0,0,0" go to this cd hide btn "Begin" show btn "Won" end setboard on randomboard global board,boardsize,numcolors,thesolution colorizehc "colorfill",(topleft of btn 1 &","& bottomright of btn 25),"0,0,0" colorizehc "colorfill","240,46,274,65","0,0,0" colorizehc "colorfill","237,87,274,124","0,0,0" colorizehc "colorfill",rect of btn "Spot","0,0,0" colorizehc "add","Creating","51,74" go to this cd if boardsize = "" then put 3 into boardsize if numcolors = "" then put 10 into numcolors put "" into thebtns put "" into alltiles repeat with b = 1 to 5 repeat with a = 1 to 5 put ((b-1)*5+a) into ab if a > boardsize or b > boardsize then hide btn ab else show btn ab put ab&"," after thebtns end if put return after alltiles end repeat end repeat delete last char of thebtns repeat with b = 1 to boardsize repeat with a = 1 to boardsize put "" into map put ((b-1)*5+a) into ab if b = 1 then put ","&random(numcolors) after map else put "," & item 3 of (line (ab-5) of alltiles) after map put ","&random(numcolors) after map put ","&random(numcolors) after map if a = 1 then put ","&random(numcolors) after map else put "," & item 2 of (line (ab-1) of alltiles) after map delete first char of map put map into line ab of alltiles put random(number of items in thebtns) into rannum put item rannum of thebtns into c delete item rannum of thebtns set name of btn c to map end repeat end repeat delete last char of alltiles put alltiles into thesolution end randomboard on checkboard global boardsize set cursor to watch repeat with b = 1 to boardsize repeat with a = 1 to boardsize if a=boardsize and b=boardsize then next repeat put ((b-1)*5+a) into ab put short name of btn ab into abname if a < boardsize then put short name of btn (ab+1) into ab1name if item 2 of abname ≠ item 4 of ab1name then exit checkboard end if end if if b < boardsize then put short name of btn (ab+5) into ab5name if item 3 of abname ≠ item 1 of ab5name then exit checkboard end if end if end repeat end repeat play "Gong" flash 6 colorizehc "add","Begin1",rect of btn "Won" colorizehc "colorfill","15,16,191,192","0,0,0",blend show btn "Begin" go to this cd end checkboard on hint global thesolution,boardsize,hintpenalty if visible of btn "Begin" is true then exit to hypercard repeat with b = boardsize down to 1 repeat with a = boardsize down to 1 put ((b-1)*5+a) into ab if short name of btn ab ≠ line ab of thesolution then exit repeat end repeat if short name of btn ab ≠ line ab of thesolution then exit repeat end repeat put 4 into hintpenalty send mousedown to btn (line ab of thesolution) send mousedown to btn (ab) put "" into hintpenalty checkboard if visible of btn "Begin" is true then exit to hypercard end hint on drawtiles global boardsize if boardsize = 5 then colorizehc "add","Digit2",rect of btn "Tiles1" colorizehc "add","Digit5",rect of btn "Tiles2" else if boardsize = 4 then colorizehc "add","Digit1",rect of btn "Tiles1" colorizehc "add","Digit6",rect of btn "Tiles2" else colorizehc "colorfill",rect of btn "Tiles1","0,0,0" colorizehc "add","Digit9",rect of btn "Tiles2" end if end drawtiles on drawcolors global numcolors if numcolors = 10 then colorizehc "add","ThinDigit1",rect of btn "Colors1" colorizehc "add","Digit0",rect of btn "Colors2" else colorizehc "colorfill",rect of btn "Colors1","0,0,0" colorizehc "add",("Digit"&numcolors),rect of btn "Colors2" end if end drawcolors -- part 1 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=15 top=16 right=53 bottom=52 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 3,9,7,3 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 3 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=50 top=16 right=53 bottom=87 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 5,8,8,9 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 4 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=85 top=16 right=53 bottom=122 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 6,4,7,8 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 5 (button) -- low flags: 80 -- high flags: 0000 -- rect: left=120 top=16 right=53 bottom=157 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 2,3,3,3 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 6 (button) -- low flags: 80 -- high flags: 0000 -- rect: left=155 top=16 right=53 bottom=192 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 4,3,7,5 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 7 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=15 top=51 right=88 bottom=52 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 7,9,7,8 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 8 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=50 top=51 right=88 bottom=87 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 8,9,1,9 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 9 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=85 top=51 right=88 bottom=122 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 7,10,7,9 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 10 (button) -- low flags: 80 -- high flags: 0000 -- rect: left=120 top=51 right=88 bottom=157 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 3,5,4,1 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 11 (button) -- low flags: 80 -- high flags: 0000 -- rect: left=155 top=51 right=88 bottom=192 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 5,10,10,8 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 12 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=15 top=86 right=123 bottom=52 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 7,7,7,10 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 13 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=50 top=86 right=123 bottom=87 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 1,10,7,7 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 14 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=85 top=86 right=123 bottom=122 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 7,1,1,10 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 15 (button) -- low flags: 80 -- high flags: 0000 -- rect: left=120 top=86 right=123 bottom=157 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 4,2,3,7 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 16 (button) -- low flags: 80 -- high flags: 0000 -- rect: left=155 top=86 right=123 bottom=192 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 8,9,2,6 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 17 (button) -- low flags: 80 -- high flags: 0000 -- rect: left=15 top=121 right=158 bottom=52 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 2,7,6,4 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 18 (button) -- low flags: 80 -- high flags: 0000 -- rect: left=50 top=121 right=158 bottom=87 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 1,5,6,7 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 19 (button) -- low flags: 80 -- high flags: 0000 -- rect: left=85 top=121 right=158 bottom=122 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 1,4,4,5 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 20 (button) -- low flags: 80 -- high flags: 0000 -- rect: left=120 top=121 right=158 bottom=157 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 3,1,2,4 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 21 (button) -- low flags: 80 -- high flags: 0000 -- rect: left=155 top=121 right=158 bottom=192 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 4,9,2,2 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 22 (button) -- low flags: 80 -- high flags: 0000 -- rect: left=15 top=156 right=193 bottom=52 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 9,10,4,3 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 23 (button) -- low flags: 80 -- high flags: 0000 -- rect: left=50 top=156 right=193 bottom=87 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 10,1,6,3 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 24 (button) -- low flags: 80 -- high flags: 0000 -- rect: left=85 top=156 right=193 bottom=122 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 1,9,4,10 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 25 (button) -- low flags: 80 -- high flags: 0000 -- rect: left=120 top=156 right=193 bottom=157 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 4,1,4,1 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 26 (button) -- low flags: 80 -- high flags: 0000 -- rect: left=155 top=156 right=193 bottom=192 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: 9,8,8,3 ----- HyperTalk script ----- on mousedown imclicked end mousedown -- part 40 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=239 top=86 right=123 bottom=276 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Spot ----- HyperTalk script ----- on mousedown global gottilenum,gottile if gottile ≠ "" then send mousedown to btn gottilenum end mousedown -- part 41 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=217 top=162 right=185 bottom=296 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Won ----- HyperTalk script ----- on mousedown global gottile colorizehc "add","Won2",rect of me hide me if gottile ≠ "" then send mousedown to btn "Spot" checkboard if visible of btn "Begin" is false then colorizehc "add","Won1",rect of me answer "You have NOT solved the puzzle yet..." with "New Game" or "Continue" if it = "New Game" then show btn "Begin" colorizehc "colorfill","15,16,191,192","0,0,0",blend go to this cd send mousedown to btn begin end if end if show me end mousedown -- part 42 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=205 top=21 right=43 bottom=309 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: SmallTitle ----- HyperTalk script ----- on mousedown if visible of btn "Begin" is false then answer "Quit this game and go back to the title page?" with "Ok" or "Cancel" if it = "Cancel" then exit mousedown end if go to card 1 openstack end mousedown -- part 43 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=217 top=162 right=185 bottom=296 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Begin ----- HyperTalk script ----- on mousedown colorizehc "add","Begin2",rect of me hide me begin colorizehc "add","Won1",rect of me end mousedown -- part 44 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=217 top=139 right=158 bottom=229 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Tiles1 -- part 45 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=228 top=139 right=158 bottom=240 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Tiles2 -- part 47 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=241 top=140 right=157 bottom=258 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Tiles -- part 48 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=264 top=139 right=158 bottom=269 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Colors1 -- part 49 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=268 top=139 right=158 bottom=280 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Colors2 -- part 50 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=280 top=140 right=157 bottom=295 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Colors -- part 52 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=205 top=46 right=65 bottom=217 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Score1 ----- HyperTalk script ----- on mousedown hint end mousedown -- part 53 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=216 top=46 right=65 bottom=228 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Score2 ----- HyperTalk script ----- on mousedown hint end mousedown -- part 54 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=227 top=46 right=65 bottom=239 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Score3 ----- HyperTalk script ----- on mousedown hint end mousedown -- part 56 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=215 top=137 right=159 bottom=260 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: ----- HyperTalk script ----- on mousedown global boardsize if visible of btn "Begin" is false then answer "You must end this game with the 'Have I Won' button before you can change the settings." exit mousedown end if add 1 to boardsize if boardsize > 5 then put 3 into boardsize drawtiles go to this cd end mousedown -- part 57 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=263 top=137 right=159 bottom=297 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: ----- HyperTalk script ----- on mousedown global numcolors if visible of btn "Begin" is false then answer "You must end this game with the 'Have I Won' button before you can change the settings." exit mousedown end if add -1 to numcolors if numcolors < 3 then put 10 into numcolors drawcolors go to this cd end mousedown -- part 58 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=293 top=44 right=65 bottom=309 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Help ----- HyperTalk script ----- on mousedown set cursor to watch colorizehc "add","Help2",rect of me hide me if visible of btn "Begin" is false then answer "Quit this game and go the help pages?" with "Ok" or "Cancel" if it = "Cancel" then colorizehc "add","Help",rect of me show me exit mousedown end if end if show me go to cd "Help" end mousedown